<template>
  <div class="setting-window">
    <div class="setting-container">
      <div class="setting-header" style="-webkit-app-region: drag">
        <div class="title">设置</div>
        <a href="javascript:void(0)" @click="close" class="close" style="-webkit-app-region: no-drag">
          <svg-icon icon-class="close"/>
        </a>
      </div>
      <el-tabs class="setting-tabs" tab-position="left">
        <el-tab-pane label="账号信息">
          <UserInfo></UserInfo>
        </el-tab-pane>
        <el-tab-pane label="通用设置">
          <CommonSetting ref="CommonSetting"></CommonSetting>
        </el-tab-pane>
        <el-tab-pane label="关于产品">关于产品</el-tab-pane>
      </el-tabs>
      <el-button @click="logoutUser()" size="mini" class="logout-user" type="danger">退出账号</el-button>
      <el-button @click="updateAllConfig()" size="mini" class="update-setting" type="success">更新配置</el-button>
    </div>
  </div>
</template>

<script>
  import { CommonSetting, UserInfo } from './components'
  import winControl from '../../../main/windowControl.js'

  export default {
    components: {
      UserInfo,
      CommonSetting
    },
    data() {
      return {}
    },
    methods: {
      close() {
        winControl.closeSettingWindow()
      },
      logoutUser() {
      },
      updateAllConfig() {
        this.$confirm('是否保存所有的修改项?', '提示', {
          lockScroll: true,
          closeOnClickModal: false,
          closeOnPressEscape: false,
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          // 这里是通知子组件自己更新自己的数据对象
          this.$refs.CommonSetting.updateConfig()
          this.$message({
            type: 'success',
            message: '保存成功（重启后生效）!'
          })
        }).catch(() => {
          console.debug('用户取消了删除')
        })
      }
    }
  }
</script>


